<?php

namespace app\admin\controller\subject;

use app\common\controller\Backend;

class Order extends Backend
{
    /**
     * 当前控制器下的一个模型属性
     */
    protected $model = null;

    // 初始化
    public function _initialize()
    {
        parent::_initialize();
        // 引入的模型
        $this->model = model('Subject.Order');
    }
    public function index()
    {
        //设置过滤方法
        $this->request->filter(['strip_tags']);

        if ($this->request->isAjax()) {
            if ($this->request->request('keyField')) {
                return $this->selectpage();
            }

            list($where, $sort, $order, $offset, $limit) = $this->buildparams();

            $total = $this->model
                ->with(['subject','business'])
                ->where($where)
                ->order($sort, $order)
                ->limit($offset, $limit)
                ->count();  //查询总数
               
            $list = $this->model
                ->with(['subject','business'])
                ->where($where)
                ->order($sort, $order)
                ->limit($offset, $limit)
                ->select();  //查询数据
            // echo   $this->SubjectOrderModel->getlastSql();exit;
            $result = array("total" => $total, "rows" => $list);

            return json($result);
        }
        return $this->view->fetch();
    }
    
}
